package br.unip.tcc.domotic.orm;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "comodo")
public class Room extends AbstractORM {
	
	private static final long serialVersionUID = 1L;
	
	private Integer roomId;
	private String roomName;
	private Double roomArea;
	private Short roomPositionXStart;
	private Short roomPositionYStart;
	private Short roomPositionXEnd;
	private Short roomPositionYEnd;
	private Floor floor;
	private Set<Device> devices = new HashSet<Device>(0);
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "cod_comodo", unique = true, nullable = false)
	public Integer getRoomId() {
		return roomId;
	}
	
	public void setRoomId(Integer roomId) {
		this.roomId = roomId;
	}
	
	@Column(name = "nom_comodo", nullable = false)
	public String getRoomName() {
		return roomName;
	}
	
	public void setRoomName(String roomName) {
		this.roomName = roomName;
	}
	
	@Column(name = "val_area_comodo", nullable = true)
	public Double getRoomArea() {
		return roomArea;
	}
	
	public void setRoomArea(Double roomArea) {
		this.roomArea = roomArea;
	}
	
	@Column(name = "pos_x_inicio", nullable = false)
	public Short getRoomPositionXStart() {
		return roomPositionXStart;
	}
	
	public void setRoomPositionXStart(Short roomPositionXStart) {
		this.roomPositionXStart = roomPositionXStart;
	}
	
	@Column(name = "pos_y_inicio", nullable = false)
	public Short getRoomPositionYStart() {
		return roomPositionYStart;
	}
	
	public void setRoomPositionYStart(Short roomPositionYStart) {
		this.roomPositionYStart = roomPositionYStart;
	}
	
	@Column(name = "pos_x_fim", nullable = false)
	public Short getRoomPositionXEnd() {
		return roomPositionXEnd;
	}
	
	public void setRoomPositionXEnd(Short roomPositionXEnd) {
		this.roomPositionXEnd = roomPositionXEnd;
	}
	
	@Column(name = "pos_y_fim", nullable = false)
	public Short getRoomPositionYEnd() {
		return roomPositionYEnd;
	}
	
	public void setRoomPositionYEnd(Short roomPositionYEnd) {
		this.roomPositionYEnd = roomPositionYEnd;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "cod_andar", nullable = false)
	public Floor getFloor() {
		return floor;
	}
	
	public void setFloor(Floor floor) {
		this.floor = floor;
	}
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "room")
	public Set<Device> getDevices() {
		return devices;
	}
	
	public void setDevices(Set<Device> devices) {
		this.devices = devices;
	}
	
}
